package cn.stacey.day11;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.junit.Test;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class DemoExcelChart1 extends Application {
	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		VBox box = new VBox();
		
//		Map<String,Number> scores=new HashMap<>();
//		Map<String,Map<String,Number>> allScores=new HashMap<>();
		Scene scene = new Scene(box);
		primaryStage.setScene(scene);
		primaryStage.show();
		
		// String path="‪D:\\文档\\scores.csv";
				String path = "D:\\文档\\scores.csv";
				String path1 = "D:\\文档\\123.txt";
				// System.out.println(new File(path).exists());
				try (BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(path), "gbk"));
						OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(path1), "gbk");

				) {

					String line;
					int count = 0;
					Map<String,Number> scores=new HashMap<>();
					Map<String,Number> scores1=new HashMap<>();
//					Map<String,Map<String,Number>> allScores=new HashMap<>();
					while ((line = is.readLine()) != null) {
						count++;

					//	System.out.println(count);
					//	System.out.println(line);
						String[] s = line.split(",");
						if((count>1)) {
							if(s[1].equals("线性代数")) {
								//s字符串数组需要转型成Number***
								scores.put(s[2], Integer.valueOf(s[0]));
//								System.out.println(scores);
								
							}else if(s[1].equals("高等数学（1）")) {
								scores1.put(s[2], Integer.valueOf(s[0]));
//								System.out.println(scores);
							}
							
							
//								
						}
					//allScores.put(s[2], scores);
					}
		
					
			box.getChildren().addAll(ChartUtils1.createLineChart("线性代数",scores));
			box.getChildren().addAll(ChartUtils1.createLineChart("高等数学（1）",scores1));
//					System.out.println(scores);
//					System.out.println(allScores);

				} catch (IOException e) {
					e.printStackTrace();
				}



	}

	public static void main(String[] args) {
		launch(args);
	}


//	public Map<String,Map<String,Number>> test() throws IOException {
//		// String path="‪D:\\文档\\scores.csv";
//		String path = "D:\\文档\\scores.csv";
//		String path1 = "D:\\文档\\123.txt";
//		// System.out.println(new File(path).exists());
//		try (BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(path), "gbk"));
//				OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(path1), "gbk");
//
//		) {
//
//			String line;
//			int count = 0;
////			Map<String,Number> scores=new HashMap<>();
//			Map<String,Number> scores=new HashMap<>();
//			Map<String,Map<String,Number>> allScores=new HashMap<>();
//			while ((line = is.readLine()) != null) {
//				count++;
//
//			//	System.out.println(count);
//			//	System.out.println(line);
//				String[] s = line.split(",");
//				if((count>1)) {
//					if(s[1].equals("线性代数")) {
//						//s字符串数组需要转型成Number***
//						scores.put(s[2], Integer.valueOf(s[0]));
//						allScores.put(s[2], scores);
//					}else if(s[1].equals("高等数学（1）")) {
//						scores.put(s[2], Integer.valueOf(s[0]));
//						allScores.put(s[2], scores);
//					}
//					
//					
//					
//				}
//			
//			}
////			System.out.println(scores);
////			System.out.println(allScores);
//
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
//		return null;
//
//	}

}
